package com.dl.controller;

import com.dl.response.CommonResult;
import com.dl.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StorageController {
    @Autowired
    private StorageService storageService;

    /**
     * 扣减库存
     */
    @RequestMapping("/storage/decrease")
    public CommonResult<String> decrease(Long productId, Integer count) {
        int result = storageService.decrease(productId, count);
        if(result>0){
            return CommonResult.createBySuccessMsg("扣减库存成功！",null);
        }else{
            return CommonResult.createByErrorMsg("扣减库失败！",null);
        }
    }
}
